import tensorflow as tf
import numpy as np


def create_rnn(name,
               cell_type:str,
               hidden_sizes: tuple or list,
               input_dim=None,
               input_var=None,
               state_var=None,):
    input_var = tf.placeholder(dtype=tf.float32, shape=input_dim, name='input')
    with tf.variable_scope(name, reuse=tf.AUTO_REUSE):
        cell = tf.nn.rnn_cell.LSTMCell(hidden_sizes[0])
        c = tf.placeholder(tf.float32, (None, hidden_sizes[0]), name='cell_state' )
        h = tf.placeholder(tf.float32, (None, hidden_sizes[0]), name='hidden_state')
        state_var = tf.contrib.rnn.LSTMStateTuple(c, h)
    
    outputs, next_state_var = tf.nn.dynamic_rnn(cell,
                                                input_var,
                                                initial_state=state_var,
                                                )
    output_var = outputs
    return input_var, state_var,  output_var, next_state_var, cell